<{include file="common/header.tpl"}>
<style type="text/css">
.label1 { color: tomato; }
.label2 { color: tomato; }
.label1 b { color: red; font-size: 1.3em; font-style: italic; }
.label2 b { color: red; font-size: 1.3em; font-style: italic; }
.games { padding: 0; margin: 0; list-style: none; }
.games label { color: green; }
</style>
	<section id="spread_one" class="column">
		
        <{if $alert_message}>
		<h4 class="alert_info"><{$alert_message}></h4>
        <{/if}>
		

		<article class="module width_3_quarter">
		<header>
			<h3 class="tabs_involved ">新建CPC渠道</h3>
		</header>
		<form action='/CPC/add_auto_channel' method='post' id="addChannelForm">
		<div class="tab_container">
			<div id="tab1" class="tab_content">
			<table class="tablesorter" cellspacing="0"> 
			<thead> 
				<tr> 
   					
    				<th width="20%">选项</th>     				
    				<th width="80%">操作</th>
				</tr> 
			</thead> 
			<tbody> 
				<tr> 
   					<td>渠道名称*:</td> 
					<td><input type='text' name="channel_name" size="24" value="" id="channel_name">&nbsp;&nbsp; (注：渠道的名字，可用中英文名 )</td> 
				</tr> 
				<tr> 
   					<td>渠道类型</td> 
					<td> 
                        <select name="chntype" onchange="channel_type_changed(this)">
                            <option value="new">创建新渠道</option>
                            <option value="current">使用现有渠道</option>
                        </select>
                    </td> 
				</tr> 
				<tr class="newchn"> 
   					<td>新渠道标识*:</td> 
					<td>ac.union.<input type='text' size="18" name="union_channel_key" value="" id="channel_key1"  onblur="if(/[^0-9a-zA-Z]/g.test(value))alert('渠道标识只允许字母和数字')"> &nbsp;&nbsp;(<span class="label1">注：只允许字母和数字, <b>新渠道</b></span>)</td> 
				</tr> 
				<tr class="hidden currchn"> 
   					<td>现有渠道标识*:</td> 
					<td><input type='text' size="18" name="yyh_channel_key" value="" id="channel_key2" > &nbsp;&nbsp;(<span class="label1"><b>已存在的</b>哇吖已有M站合作渠道, 比如 ac.p.htc, ax.ex.BaiduWL 等</span>)</td> 
				</tr> 

				<tr> 
   					<td>渠道描述:</td> 
					<td><input type="text" name='desc' value="" id="channel_desc"></td>
				</tr> 

				<tr>
					<td colspan="2" style="text-align:center">
						<input type="submit" class="bulid_action fw spread_submit" value="提交">
					</td>
				</tr>
			</tbody> 
			</table>
			</div><!-- end of #tab1 -->
		</div><!-- end of .tab_container -->
		</form>	
		</article><!-- end of content manager article -->
		<div class="clear"></div>
	</section>
	<script>
function channel_type_changed(html_input)
{
    var val = $(html_input).val();
    if (val == 'new')
    {
        $('.currchn').hide();
        $('.newchn').show();
    }
    else
    {
        $('.currchn').show();
        $('.newchn').hide();
    }
}
		var flag = false;
		$('#channel_key1').blur(function () {
			var channel  = $('#channel_key1').val();	
            $.get('/CPC/has_channel?channel=ac.union.' + channel, {} ,function (data) {
					if(data == '1'){
						alert('要创建的新渠道已存在');
						flag = true;
					}else{
						flag = false;
					}
            } , 'json');
		});
		
		$('#channel_key2').blur(function () {
			var key2  = $('#channel_key2').val();	
            if (! key2)
            {
            	alert('现有渠道名称不合法');
            }
		});
		
		$('#addChannelForm').submit(function() {
			return confirm('是否确定添加此渠道？');
			
		});
	</script>
<{include file="common/footer.tpl"}>
